package com.work.xxzl.mvp.model;

import com.work.xxzl.bean.CommonBean;
import com.work.xxzl.cache.Ckey;
import com.work.xxzl.cache.SPutils;
import com.work.xxzl.httpretrofit.MultipartBodyUtils;
import com.work.xxzl.httpretrofit.MyCallback;
import com.work.xxzl.httpretrofit.RetrofitManager;
import com.work.xxzl.mvp.callback.MvpCallback;
import com.work.xxzl.mvp.contract.PlayVideoContract;

import retrofit2.Call;

/**
 * author: Wangzhan
 * date :2018/9/19 0019 09:49
 * version:2.0.0
 * description:上传视频请求
 */

public class PlayVideoModel implements PlayVideoContract.Model {
    @Override
    public void UploadVideo(String filepath, final MvpCallback<CommonBean> callback) {
        Call<CommonBean> call = RetrofitManager.getInstance().uploadFile(SPutils.get(Ckey.USERID), MultipartBodyUtils.getPart(filepath));
        call.enqueue(new MyCallback<CommonBean>() {

            @Override
            public void onSuccess(CommonBean response) {
                callback.onSuccess(response);
            }

            @Override
            public void onFailure(int errorCode, String errMsg) {
                callback.onFailure(errorCode, errMsg);
            }

            @Override
            public void onComplete() {
                callback.onComplete();
            }

        });
    }
}
